package com.itheima.tlias84.mapper;

import com.itheima.tlias84.dto.ReportEmpGenderDTO;
import com.itheima.tlias84.dto.SelectEmpDTO;
import com.itheima.tlias84.dto.SelectEmpDetailDTO;
import com.itheima.tlias84.entity.Emp;
import com.itheima.tlias84.po.InsertEmpParam;
import com.itheima.tlias84.po.SelectEmpPageParam;
import com.itheima.tlias84.po.UpdateEmpParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 都是标识Dao层的注解
 *
 * @Mapper -->mybatis提供：标识接口是Mapper接口
 * @Repository -->spring提供：标识接口是Dao接口
 */
//@Repository
@Mapper
public interface EmpMapper {

    List<SelectEmpDTO> selectEmpByPage(@Param("p") SelectEmpPageParam param);

    int batchDelete(@Param("ids") List<Integer> ids);

    int insertEmp(@Param("p") InsertEmpParam param);

    int updateEmp(@Param("p") UpdateEmpParam param);

    SelectEmpDetailDTO selectEmpById(@Param("id") Integer id);

    @Select("select count(gender) as value, case gender when 1 then '男性' when 2 then '女性' end as name " +
            "from emp e group by gender")
    List<ReportEmpGenderDTO> countEmpGender();

    @Select("select job from emp")
    List<Integer> countEmpJob();

    @Select("select id,username,password from emp where username = #{username}")
    Emp selectEmpByUsername(@Param("username") String username);

    List<Emp> selectEmpAll();
}
